package com.laery0.xixin.service.impl;

import com.laery0.xixin.mapper.SetmealMapper;
import com.laery0.xixin.po.ResponseBean;
import com.laery0.xixin.po.Setmeal;
import com.laery0.xixin.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SetmealServiceImpl implements SetmealService {
    @Autowired
    private SetmealMapper setmealMapper;

    @Override
    public ResponseBean<List<Setmeal>> listSetmealByType(Integer type) {
        List<Setmeal> setmealList = setmealMapper.listSetmealByType(type);
        if (setmealList != null && setmealList.size() > 0) {
            return new ResponseBean<>(setmealList);
        } else {
            return new ResponseBean<>(601, "没有查到" + ((type==1) ? "男" : "女" ) + "性的套餐明细");
        }
    }

    @Override
    public ResponseBean<Setmeal> getSetmealById(Integer smId) {
        Setmeal setmealById = setmealMapper.getSetmealById(smId);
        if (setmealById != null) {
            return new ResponseBean<>(setmealById);
        } else {
            return new ResponseBean<>(601, "没有查到id为" + smId + "的套餐明细");
        }
    }
}
